package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.PageResponseResult;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.ChannelDto;
import com.heima.model.wemedia.pojos.WmChannel;
import com.heima.wemedia.service.WmChannelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/channel")
public class ChannelController {
    @Autowired
    private WmChannelService wmChannelService;
    @GetMapping("/channels")
    public ResponseResult channels(){
        return wmChannelService.channelList();
    }
    @PostMapping("/save")
    public ResponseResult saveChannel(WmChannel wmChannel){
        return wmChannelService.saveChannel(wmChannel);
    }
    @PostMapping("/list")
    public PageResponseResult list(ChannelDto dto){
        return wmChannelService.findList(dto);
    }
    @PostMapping("/update")
    public ResponseResult update(WmChannel wmChannel){
        return wmChannelService.updateChannel(wmChannel);
    }
    @GetMapping("/del/{id}")
    public ResponseResult del(@PathVariable("id") Integer id){
        return wmChannelService.delete(id);
    }

}
